#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

#define endl '\n'

struct Car{
    ll d,v,a;
    bool ignore=0;
} cars[100005];

ll p[100005];
int s[100005];

int bin1(int l, int r,const Car &c, int V){
    // c.a < 0
    while(l<=r){
        int mid=l+(r-l)/2;
        if(c.v*c.v+2*c.a*(p[mid]-c.d)>V*V){
            l=mid+1;
        }
        else r=mid-1;
    }
    return r;
}

int bin2(int l, int r,const Car &c, int V){
    // c.a > 0
    while(l<=r){
        int mid=l+(r-l)/2;
        if(c.v*c.v+2*c.a*(p[mid]-c.d)<V*V){
            l=mid+1;
        }
        else r=mid-1;
    }
    return r;
}

int main(){
    freopen("detect.in", "r", stdin);
    #ifndef DEBUG
    freopen("detect.out", "w", stdout);
    #endif
    cin.tie(0)->sync_with_stdio(0);
    cout.tie(0);
    int T;
    queue<pair<int,int>> q;
    queue<pair<int,int>> q2;
    cin>>T;
    while(T--){
        int n,m;
        ll L,V;
        cin>>n>>m>>L>>V;
        for(int i=0;i<n;i++){
            auto&c = cars[i];
            c.ignore=0;
            cin>>c.d>>c.v>>c.a;
            if((c.a<=0&&c.v<V)||(c.a>=0&&c.v*c.v+2*c.a*(L-c.d)<=V*V)){
                i--;n--;
            }
        }
        for(int i=1;i<=m;i++) cin>>p[i];
        int ans=0;
        for(int i=0;i<n;i++){
            auto&c = cars[i];
            if(c.a==0){
                if(c.v>V&&c.d<=p[m]) ans++;
                else c.ignore=1;
            }
            else if(c.a<0){
                int pos=*lower_bound(p+1,p+m+1,c.d);
                if(c.v*c.v+2*c.a*(pos-c.d)>V*V){
                    ans++;
                }
                else c.ignore=1;
            }
            else {
                if(c.d<=p[m]&&c.v*c.v+2*c.a*(p[m]-c.d)>V*V){
                    ans++;
                }
                else c.ignore=1;
            }
        }
        cout<<ans<<' ';
        for(int i=0;i<n;i++){
            const auto&c = cars[i];
            if(c.ignore) continue;
            if(c.a==0){
                q.push({lower_bound(p+1,p+m+1,c.d)-p,m});
            }
            else if(c.a<0){
                int l=lower_bound(p+1,p+m+1,c.d)-p;
                int r=bin1(l,m,c,V);
                q.push({l,r});
            }
            else {
                int l=bin2(lower_bound(p+1,p+m+1,c.d)-p,m,c,V);
                q.push({l,m});
            }
        }
        while(!q.empty()){
            auto x=q.front();q.pop();q2.push(x);
            s[x.first]++;s[x.second+1]--;
        }
        vector<int> mark;
        while(!q2.empty()){
            ll cur=0;
            int maxp=0;
            ll maxc=0;
            for(int i=1;i<=m;i++){
                cur+=s[i];
                if(cur>maxc) maxc=cur,maxp=i;
            }
            mark.push_back(maxp);
            int sz=q2.size();
            while(sz--){
                auto x=q2.front();q2.pop();
                for(auto&k:mark){
                    if(x.first<=k&&k<=x.second){
                        goto ed;
                    }
                    // cerr<<x.first<<' '<<x.second<<' '<<p[x.first]<<' '<<p[x.second]<<endl;
                }
                q2.push(x);
                continue;
                ed: s[x.first]--;s[x.second+1]++;
            }
        }
        cout<<m-mark.size()<<endl;
        // cerr<<T<<endl;
    }
    return 0;
}